﻿using IdentityModel.Client;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Http.Client.Authentication;

namespace Demo.PcWebSite.Tokens
{

    /// <summary>
    /// 
    /// </summary>
    public class TokenRemoteServiceHttpClientAuthenticator : IRemoteServiceHttpClientAuthenticator, ISingletonDependency
    {

        /// <summary>
        /// 发送Token到指定服务
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public Task Authenticate(RemoteServiceHttpClientAuthenticateContext context)
        {
            HttpClient httpClient = context.Client;

            // 2、获取token

            // 3、传递token (本质：都是请求头)
            httpClient.SetBearerToken(TokenSave.Token);

            return Task.CompletedTask;
        }


    }
}
